
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>

typedef NS_ENUM (NSInteger, XMSNetWorkReachabilityType)
{
    XMSNetWorkReachabilityTypeNotReachable = 0,
	XMSNetWorkReachabilityTypeReachableViaWiFi,
	XMSNetWorkReachabilityTypeReachableViaWWAN
};

typedef NS_ENUM (NSInteger, XMSNetWorkAccessType)
{
    XMSNetWorkAccessTypeNone,
    XMSNetWorkAccessType2G,
    XMSNetWorkAccessType3G,
    XMSNetWorkAccessType4G,
    XMSNetWorkAccessTypeWifi
};

extern NSString *const XMSNetWorkReachabilityStatusChangedNotification;

@interface XMSNetWorkReachability: NSObject
{

}

//reachabilityWithHostName- Use to check the reachability of a particular host name. 
+ (XMSNetWorkReachability*) reachabilityWithHostName: (NSString*) hostName;

//reachabilityWithAddress- Use to check the reachability of a particular IP address. 
+ (XMSNetWorkReachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;

+(XMSNetWorkReachability*)reachabilityWithAddressIP:(NSString*)ip port:(NSUInteger)port;

//reachabilityForInternetConnection- checks whether the default route is available.  
//  Should be used by applications that do not connect to a particular host
+ (XMSNetWorkReachability*) reachabilityForInternetConnection;

//reachabilityForLocalWiFi- checks whether a local wifi connection is available.
+ (XMSNetWorkReachability*) reachabilityForLocalWiFi;

+ (XMSNetWorkAccessType)currentNetworkAccessType;

//Start listening for reachability notifications on the current run loop
- (BOOL) startNotifier;
- (void) stopNotifier;

-(void)reachabilityChangedBlock:(void(^)(XMSNetWorkReachability* reachability))block;

- (XMSNetWorkReachabilityType) currentReachabilityStatus;
//WWAN may be available, but not active until a connection has been established.
//WiFi may require a connection for VPN on Demand.
- (BOOL)connectionRequired;

- (BOOL)isNotReachable;

+(void)initReachability:(XMSNetWorkReachability*(^)())init;

+(XMSNetWorkReachability*)reachability;

+(void)releaseReachability;

@end


